#include "tcl_mtk_dtv_tv.h"
TCL_MTK_DTV_TV::TCL_MTK_DTV_TV()
{

}

/*
TCL_MTK_DTV_TV::TCL_MTK_DTV_TV()
{
}

TCL_MTK_DTV_TV::TCL_MTK_DTV_TV(uint ch_val,
                               uint freq,
                               uint bandwidth,
                               short nw_id,
                               short on_id,
                               short ts_id,
                               short prog_id,
                               uint sys_rate,
                               uint mod,
                               uint nw_flag,
                               QString &name)
{
    ui4_ch_val=ch_val;
    ui4_freq=freq;
    e_bandwidth=bandwidth;
    ui2_nw_id=nw_id;
    ui2_on_id=on_id;
    ui2_ts_id=ts_id;
    ui2_prog_id=prog_id;
    ui4_sys_rate=sys_rate;
    e_mod=mod;
    ui4_nw_flag=nw_flag;
    ps_name=name;
}
*/

int TCL_MTK_DTV_TV::Read_Data(QDataStream &in)
{
    qint8 dtv;
    in>>dtv;
    ui_dtv=dtv;
     in>>ui2_nw_id
      >>ui2_on_id
      >>ui2_ts_id
      >>ui2_prog_id
      >>ui4_ch_val
      >>ui4_freq
      >>e_bandwidth
      >>ui4_sys_rate
      >>e_mod
      >>ui4_nw_flag
    >>ps_name;
    return 0;
}

int TCL_MTK_DTV_TV::Write_Data(QDataStream &out)
{
    qint8 ch=ui_dtv;
  out<<ch
     <<ui2_nw_id
     <<ui2_on_id
     <<ui2_ts_id
     <<ui2_prog_id
     <<ui4_ch_val
     <<ui4_freq
     <<e_bandwidth
     <<ui4_sys_rate
     <<e_mod
     <<ui4_nw_flag
     <<ps_name;
    return 0;
}


void TCL_MTK_DTV_TV::set_Data(int order,QVariant value)
{
   QString tmp;
   char *char_str=NULL;
     switch(order)
     {
     case 0:
	  ui4_ch_val=value.toUInt();
	  break;
     case 1:
         tmp=value.toString();
         char_str=new char(2);
         memcpy(char_str,tmp.toStdString().c_str(),2);
          ui_dtv=char_str[0];
          //delete char_str;
	  break;
     case 2:
	  ui4_freq=value.toUInt();
	 
	  break;
     case 3:
	  e_bandwidth=value.toUInt();
	 
	  break;
     case 4:
	  ui2_nw_id=(short)value.toInt();
	  break;
     case 5:
	  ui2_ts_id=(short)value.toInt();
	  break;
     case 6:
	  ui2_on_id=(short)value.toInt();
	  break;
     case 7:
 	  ui2_prog_id=(short)value.toInt();
	  break;
     case 8:
	  ui4_sys_rate=value.toUInt();
	  break;
     case 9:
          e_mod=value.toUInt();
	  break;
     case 10:
	  ui4_nw_flag=value.toUInt();
	  break;
     case 11:
	  ps_name=value.toString();
	  break;
     default:
	  qDebug("In MTK DTV set_Data:order error!");

     }
    // delete char_str;

}
